<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex searchContent_flex_0"
        :style="{height:(234+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub searchContent_fd0_0'>
          <view class='flex flex-wrap align-center searchContent_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  searchContent_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='searchContent_fd0_0_c1_c0'>搜索</text>
          </view>
          <view class='flex flex-wrap align-center justify-end searchContent_fd0_0_c0'>
          </view>
        </view>
        <view class='flex flex-wrap align-center searchContent_fd0_1'>
          <image class='searchContent_fd0_1_c0' mode="aspectFit" :src='STATIC_URL+"17.png"'></image>
          <input class='flex-sub searchContent_fd0_1_c1' type="text" :placeholder="`这里是搜索内容`" confirm-type="done"
            :maxlength="-1" placeholder-style="color:#999;font-size:28rpx" @confirm="getgoodsListFunc()"
            v-model="keyworld" />
        </view>

      </view>
      <view :style="{height: (234+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout" >
        <template v-for='(item,key0) in productList'>
          <view class='flex flex-wrap align-center searchContent_fd1_0' @tap.stop="handleJumpDiy" data-type="navigateTo"
            :data-url="`/pages/homePages/farmtoolsDetail/farmtoolsDetail?id=${item.id}`" v-if=" date=='1'" :key='key0'>
            <image class='searchContent_fd1_0_c0' mode="aspectFill" :src='item.thumb'></image>
            <view class='flex flex-direction flex-wrap align-stretch flex-sub'>
              <text class='searchContent_fd1_0_c1_c0'>{{item.name}}</text>
              <view class='flex flex-wrap align-center searchContent_fd1_0_c1_c1'>
                <text class='searchContent_fd1_0_c1_c1_c0' v-for="(itemC,indexC) in item.category_name"
                  v-if="item.category_name.length&& indexC<2">{{itemC}}</text>
                <!-- <text class='searchContent_fd1_0_c1_c1_c1'>二级分类</text> -->
              </view>
              <view class='flex flex-wrap align-center'>
                <text class='searchContent_fd1_0_c1_c2_c0'>{{item.shop_price || 0}}</text>
                <text class='searchContent_fd1_0_c1_c2_c1'>积分</text>
                <image class='searchContent_fd1_0_c1_c2_c2' mode="aspectFit" :src='STATIC_URL+"16.png"'></image>
              </view>
            </view>
          </view>
        </template>

        <view class='flex flex-direction flex-wrap align-center justify-center' v-if=" productList.length<=0">
          <image class='searchContent_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"20.png"'></image>
          <text class='searchContent_fd1_1_c1'>对不起，暂无该农具，敬请期待！</text>
        </view>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "date": "1",
        "productList": [],
        "keyworld": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },
      appSearchHistory() { // 搜索历史
        return this.$store.state.appSearchHistory
      }
    },
    watch: {},
    onLoad(options) {
      let {
        keyworld
      } = options
      if (keyworld !== undefined) this.keyworld = keyworld
      this.getgoodsListFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {
      this.getgoodsListFunc()
    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //搜索
      searchFunc() {
        this.$store.commit('appSearchHistoryAdd', {
          "name": this.keyworld
        })
        this.getgoodsListFunc()
      },
      //获取商品列表
      async getgoodsListFunc() {
        //请求方法
        //数据验证

        let dataproductList = await this.$api.get(global.apiUrls.post62b9118254ebf, {
          keywords: this.keyworld,
          page: '1',
          list_rows: '15'
        });

        if (dataproductList.data.code != 1) {
          this.$message.info(dataproductList.data.msg);
          return
        }
        let infoproductList = dataproductList.data.data;
        this.productList = infoproductList.data
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: var(--benbenbgColor0);
    background-size: 100% auto;
  }

  .searchContent_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 234rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .searchContent_fd0_1_c1 {
    color: var(--benbenFontColor0);
    font-size: 28rpx;
    font-weight: 400;
  }

  .searchContent_fd0_1_c0 {
    width: 40rpx;
    height: 40rpx;
    margin: 0rpx 16rpx 0rpx 0rpx;
  }

  .searchContent_fd0_1 {
    background: #F8F8F8;
    border-radius: 36rpx 36rpx 36rpx 36rpx;
    padding: 16rpx 0rpx 16rpx 24rpx;
    margin: 31rpx 32rpx 25rpx 32rpx;
  }

  .searchContent_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 500;
    color: #333;
    line-height: 88rpx;
  }

  .searchContent_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .searchContent_fd0_0_c0 {
    width: 120rpx;
  }

  .searchContent_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .searchContent_fd1_1_c1 {
    color: #333333;
    font-size: 24rpx;
    font-weight: 400;
  }

  .searchContent_fd1_1_c0 {
    width: 300rpx;
    height: 300rpx;
    margin: 156rpx 0rpx 0rpx 0rpx;
  }

  .searchContent_fd1_0_c1_c2_c2 {
    width: 48rpx;
    height: 48rpx;
    margin: 0rpx 0rpx 0rpx auto;
  }

  .searchContent_fd1_0_c1_c2_c1 {
    color: rgba(230, 56, 56, 1);
    font-size: 24rpx;
    font-weight: 700;
  }

  .searchContent_fd1_0_c1_c2_c0 {
    color: rgba(230, 56, 56, 1);
    font-size: 36rpx;
    font-weight: 700;
  }

  .searchContent_fd1_0_c1_c1_c1 {
    color: #999999;
    font-size: 24rpx;
    font-weight: 400;
  }

  .searchContent_fd1_0_c1_c1_c0 {
    color: #999999;
    font-size: 24rpx;
    font-weight: 400;
    margin: 0rpx 16rpx 0rpx 0rpx;
  }

  .searchContent_fd1_0_c1_c1 {
    margin: 0rpx 0rpx 55rpx 0rpx;
  }

  .searchContent_fd1_0_c1_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 500;
    margin: 0rpx 0rpx 24rpx 0rpx;
  }

  .searchContent_fd1_0_c0 {
    width: 200rpx;
    height: 200rpx;
    margin: 0rpx 24rpx 0rpx 0rpx;
    border-radius: 16rpx;
  }

  .searchContent_fd1_0 {
    background: #FFFFFF;
    margin: 24rpx 24rpx 0rpx 24rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    padding: 32rpx 24rpx 32rpx 24rpx;
  }
</style>
